package com.atguigu.flink.chapter10.join;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

/**
 * @Author lzc
 * @Date 2023/6/29 14:39
 */
public class ConsumeUpsertKafkaWithUpsertKafka {
    public static void main(String[] args) {
        Configuration conf = new Configuration();
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
        env.setParallelism(1);
        StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);
    
        tEnv.executeSql("create table t14(" +
                            " id string, " +
                            " name string," +
                            " age int," +
                            " primary key(id) not enforced " +
                            ")with(" +
                            "  'connector' = 'upsert-kafka', " +
                            "  'topic' = 't14', " +
                            "  'properties.bootstrap.servers' = 'hadoop162:9092', " +
                            "  'key.format' = 'json', " +
                            "  'value.format' = 'json' " +
                            ")");
    
        tEnv.sqlQuery("select * from t14").execute().print();
    }
}
/*
普通的 kafka 消费的时候, 会自动的忽略 value 是 null 那些 recorde
 */